//
//  InterviewExperienceTableViewCell.m
//  MyProject
//
//  Created by jiaming yan on 2018/3/5.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "InterviewExperienceTableViewCell.h"

@implementation InterviewExperienceTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.starRatingView.maximumValue = 5;
    self.starRatingView.minimumValue = 0;
    self.starRatingView.spacing = 18;//间距，星星大小是去掉间距后计算的
    //    self.starRatingView.value = 0;
//    self.starRatingView.delegate = self;
    self.starRatingView.tintColor = UIColorFromRGB(0x1eb0c1);//星星的颜色。
    self.starRatingView.allowsHalfStars = YES;//是否有半星
    self.starRatingView.emptyStarImage = [[UIImage imageNamed:@"ic_stars_没选中没选中Unselected"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    self.starRatingView.filledStarImage = [[UIImage imageNamed:@"ic_stears_Selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    
    
    _tagBackView.completion = ^(NSArray *selectTags,NSInteger currentIndex) {
        NSLog(@"selectTags:%@ currentIndex:%ld",selectTags, (long)currentIndex);
    };
    _tagBackView.layout.scrollDirection = UICollectionViewScrollDirectionVertical;
    
    HXTagAttribute *model = [[HXTagAttribute alloc]init];
    model.borderWidth  = 0;
    model.borderColor  = kClearColor;
    model.cornerRadius  = 8;
    model.titleSize  = 11;
    model.textColor  = UIColorFromRGB(0x00BCCC);
    model.selectedTextColor  = UIColorFromRGB(0x00BCCC);
    model.normalBackgroundColor  = UIColorFromRGB(0xE7F4F6);
    model.selectedBackgroundColor  = UIColorFromRGB(0xE7F4F6);
    model.tagSpace  = 15;
    
    _tagBackView.tagAttribute = model;
    
    [_tagBackView reloadData];
    
//    _tagBackView.tags = @[@"环境高大上",@"聊的很开心"];
//
//    [_tagBackView reloadData];
//    CGFloat height = [HXTagsView getHeightWithTags:self.tagBackView.tags layout:self.tagBackView.layout tagAttribute:self.tagBackView.tagAttribute width:kScreenWidth-30];
//    self.heightOfTags.constant = height;
}
- (void)HCSStarRatingView:(HCSStarRatingView *)HCSStarRatingView theValueIs:(CGFloat)value{
    if (value<0||value>5) {
        return;
    }
    
//    _valueLabel.text = [NSString stringWithFormat:@"%zd分",labs((NSInteger)(value*2))];
//    _model.score = labs((NSInteger)(value*2));
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(PositionReviewModel *)model {
    _model = model;
    
//    [self.headerIV sd_setImageWithURL:ImageURLWithKey(model) placeholderImage:<#(UIImage *)#>]
    self.dateL.text = model.publishedTime;
    self.contentLabel.text = model.publishedContent;
    self.nameL.text = model.publisher;
    
    NSArray *tags = [model.tags componentsSeparatedByString:@","];
    _tagBackView.tags = tags;
    [_tagBackView reloadData];
    
    CGFloat height = [HXTagsView getHeightWithTags:self.tagBackView.tags layout:self.tagBackView.layout tagAttribute:self.tagBackView.tagAttribute width:kScreenWidth-30];
    self.heightOfTags.constant = height;
}

@end
